<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    

    <title>Installing MXNet &mdash; mxnet  documentation</title>
    
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

    
    <link rel="stylesheet" href="../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />

    <link rel="stylesheet" href="../_static/mxnet.css" type="text/css">
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>

    <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
    
    <script type="text/javascript" src="../_static/underscore.js"></script>
    
    <script type="text/javascript" src="../_static/searchtools_custom.js"></script>
    
    <script type="text/javascript" src="../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../_static/selectlang.js"></script>
    

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/javascript"> jQuery(function() { Search.loadIndex("/searchindex.js"); Search.init();}); </script>

    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new
      Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

      ga('create', 'UA-96378503-1', 'auto');
      ga('send', 'pageview');

    </script>

    <!-- -->
    <!-- <script type="text/javascript" src="../_static/jquery.js"></script> -->
    <!-- -->
    <!-- <script type="text/javascript" src="../_static/underscore.js"></script> -->
    <!-- -->
    <!-- <script type="text/javascript" src="../_static/doctools.js"></script> -->
    <!-- -->
    <!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> -->
    <!-- -->
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" /> 

    <link rel="icon" type="image/png" href="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-icon.png">
  </head>
  <body role="document" background="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-background-compressed.jpeg">
    <div class='content-block'><div class="navbar navbar-fixed-top">
  <div class="container" id="navContainer">
    <div id="header-inner" class="innder">
      <h1 id="logo-wrap">
        <a href="../" id="logo"><img src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet_logo.png"></a>
      </h1>
      <nav id="main-nav" class='nav-bar'>
        <a class="main-nav-link" href="../install/index.html">Install</a>

        <span id="dropdown-menu-position-anchor">
          <a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">Gluon <span class="caret"></span></a>
          <ul id="package-dropdown-menu" class="dropdown-menu navbar-menu">
            <li><a class="main-nav-link" href="../gluon/index.html">About</a></li>
            <li><a class="main-nav-link" href="http://gluon.mxnet.io">Tutorials</a></li>
          </ul>
        </span>
        
     <span id="dropdown-menu-position-anchor">
          <a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">API <span class="caret"></span></a>
          <ul id="package-dropdown-menu" class="dropdown-menu navbar-menu">
            <li><a class="main-nav-link" href="../api/python/index.html">Python</a></li>
            <li><a class="main-nav-link" href="../api/scala/index.html">Scala</a></li>
            <li><a class="main-nav-link" href="../api/r/index.html">R</a></li>
            <li><a class="main-nav-link" href="../api/julia/index.html">Julia</a></li>
            <li><a class="main-nav-link" href="../api/c++/index.html">C++</a></li>
            <li><a class="main-nav-link" href="../api/perl/index.html">Perl</a></li>
          </ul>
        </span>

         <span id="dropdown-menu-position-anchor-docs">
          <a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">Docs <span class="caret"></span></a>
          <ul id="package-dropdown-menu-docs" class="dropdown-menu navbar-menu">
            <li><a class="main-nav-link" href="../tutorials/index.html">Tutorials</a>
            <li><a class="main-nav-link" href="../faq/index.html">FAQ</a></li>
            <li><a class="main-nav-link" href="../architecture/index.html">Architecture</a></li>
            <li><a class="main-nav-link" href="https://github.com/apache/incubator-mxnet/tree/master/example">Examples</a></li>
            <li><a class="main-nav-link" href="../api/python/gluon/model_zoo.html">Gluon Model Zoo</a></li>
          </ul>
        </span>


        <a class="main-nav-link" href="https://github.com/dmlc/mxnet">Github</a>

        <span id="dropdown-menu-position-anchor-community">
          <a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">Community <span class="caret"></span></a>
          <ul id="package-dropdown-menu-community" class="dropdown-menu navbar-menu">
            <li><a class="main-nav-link" href="../community/index.html">Community</a></li>
            <li><a class="main-nav-link" href="../community/contribute.html">Contribute</a></li>
            <li><a class="main-nav-link" href="../community/powered_by.html">Powered By</a></li>
            <li><a class="main-nav-link" href="http://discuss.mxnet.io">Discuss</a></li>
          </ul>
        </span>
      </nav>
      <script> function getRootPath(){ return "../" } </script>
      <div class="burgerIcon dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">☰</a>
          <ul id="burgerMenu" class="dropdown-menu">
              <li><a href="../install/index.html">Install</a></li>
              <li><a class="main-nav-link" href="../tutorials/index.html">Tutorials</a></li>
              <li class="dropdown-submenu">
                <a href="#" tabindex="-1">Community</a>
                <ul class="dropdown-menu">
                  <li><a tabindex="-1"  href="../community/index.html">Community</a></li>
                  <li><a tabindex="-1"  href="../community/contribute.html">Contribute</a></li>
                  <li><a tabindex="-1"  href="../community/powered_by.html">Powered By</a></li>
                </ul>
              </li>
              
              <li class="dropdown-submenu">
                <a href="#" tabindex="-1">API</a>
                <ul class="dropdown-menu">
                  
                    <li><a tabindex="-1" href="../api/python/index.html">Python</a>
                    </li>
                  
                    <li><a tabindex="-1" href="../api/scala/index.html">Scala</a>
                    </li>
                  
                    <li><a tabindex="-1" href="../api/r/index.html">R</a>
                    </li>
                  
                    <li><a tabindex="-1" href="../api/julia/index.html">Julia</a>
                    </li>
                  
                    <li><a tabindex="-1" href="../api/c++/index.html">C++</a>
                    </li>
                  
                    <li><a tabindex="-1" href="../api/perl/index.html">Perl</a>
                    </li>
                  
                </ul>
              </li>
              
              <li class="dropdown-submenu">
                <a href="#" tabindex="-1">Docs</a>
                <ul class="dropdown-menu">
                  <li><a tabindex="-1"  href="../tutorials/index.html">Tutorials</a></li>
                  <li><a tabindex="-1"  href="../faq/index.html">FAQ</a></li>
                  <li><a tabindex="-1"  href="../architecture/index.html">Architecture</a></li>
                  <li><a tabindex="-1"  href="https://github.com/apache/incubator-mxnet/tree/master/example">Examples</a></li>
                  <li><a tabindex="-1"  href="../api/python/gluon/model_zoo.html">Gluon Model Zoo</a></li>
                </ul>
              </li>
              <li><a href="../architecture/index.html">Architecture</a></li>
		      <li><a class="main-nav-link" href="https://github.com/dmlc/mxnet">Github</a></li>
          </ul>
      </div>
      <div class="plusIcon dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
        <ul id="plusMenu" class="dropdown-menu dropdown-menu-right"></ul>
      </div>
      <div id="search-input-wrap">
          
<form class="" role="search" action="../search.html" method="get" autocomplete="off">
  <div class="form-group inner-addon left-addon">
    <i class="glyphicon glyphicon-search"></i>
    <input type="text" name="q" class="form-control" placeholder="Search">
  </div>
  <input type="hidden" name="check_keywords" value="yes" />
  <input type="hidden" name="area" value="default" />
  
</form>
          <div id="search-preview"></div>
      </div>
      <div id='searchIcon'>
          <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
      </div>
      <!-- <div id="lang-select-wrap"> -->
      <!--   <label id="lang-select-label"> -->
      <!--     <\!-- <i class="fa fa-globe"></i> -\-> -->
      <!--     <span></span> -->
      <!--   </label> -->
      <!--   <select id="lang-select"> -->
      <!--     <option value="en">Eng</option> -->
      <!--     <option value="zh">中文</option> -->
      <!--   </select> -->
      <!-- </div> -->
  <!--     <a id="mobile-nav-toggle">
        <span class="mobile-nav-toggle-bar"></span>
        <span class="mobile-nav-toggle-bar"></span>
        <span class="mobile-nav-toggle-bar"></span>
      </a> -->
    </div>
  </div>
</div>
    
    
    <script type="text/javascript">
        $('body').css('background', 'white');
    </script>
    <div class="container">
      <div class="row">
        <div class="sphinxsidebar leftsidebar" role="navigation" aria-label="main navigation">
          <div class="sphinxsidebarwrapper">
            
  <ul>
<li class="toctree-l1"><a class="reference internal" href="../api/python/index.html">Python Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/r/index.html">R Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/julia/index.html">Julia Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/c++/index.html">C++ Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/scala/index.html">Scala Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/perl/index.html">Perl Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../faq/index.html">HowTo Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../architecture/index.html">System Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/index.html">Community</a></li>
</ul>

          </div>
        </div>
        <div class="content">
          <div class="page-tracker"></div>
          
  <div class="section" id="installing-mxnet">
<span id="installing-mxnet"></span><h1>Installing MXNet<a class="headerlink" href="#installing-mxnet" title="Permalink to this headline">¶</a></h1>
<p>Indicate your preferred configuration. Then, follow the customized commands to install <em>MXNet</em>.</p>
<script type="text/javascript" src='../_static/js/options.js'></script><!-- START - OS Menu --><div class="btn-group opt-group" role="group">
  <button type="button" class="btn btn-default opt active">Linux</button>
  <button type="button" class="btn btn-default opt">MacOS</button>
  <button type="button" class="btn btn-default opt">Windows</button>
  <button type="button" class="btn btn-default opt">Cloud</button>
  <button type="button" class="btn btn-default opt">Devices</button>
</div><!-- START - Language Menu --><div class="linux macos windows">
<div class="btn-group opt-group" role="group">
  <button type="button" class="btn btn-default opt active">Python</button>
  <button type="button" class="btn btn-default opt">Scala</button>
  <button type="button" class="btn btn-default opt">R</button>
  <button type="button" class="btn btn-default opt">Julia</button>
  <button type="button" class="btn btn-default opt">Perl</button>
</div>
</div><!-- No CPU GPU for other Devices -->
<div class="linux macos windows cloud">
<div class="btn-group opt-group" role="group">
  <button type="button" class="btn btn-default opt active">CPU</button>
  <button type="button" class="btn btn-default opt">GPU</button>
</div>
</div><!-- other devices -->
<div class="devices">
<div class="btn-group opt-group" role="group">
  <button type="button" class="btn btn-default opt active">Raspberry Pi</button>
  <button type="button" class="btn btn-default opt">NVIDIA Jetson TX2</button>
</div>
</div><!-- Linux Python GPU Options --><div class="linux macos windows">
<div class="python">
<div class="cpu gpu">
<div class="btn-group opt-group" role="group">
  <button type="button" class="btn btn-default opt active">Pip</button>
  <button type="button" class="btn btn-default opt">Virtualenv</button>
  <button type="button" class="btn btn-default opt">Docker</button>
  <button type="button" class="btn btn-default opt">Build from Source</button>
</div>
</div>
</div>
</div><!-- END - Main Menu --><!-- START - Linux Python CPU Installation Instructions --><div class="linux">
<div class="python">
<div class="cpu"><p>The following installation instructions have been tested on Ubuntu 14.04 and 16.04.</p>
<div class="pip">
<br/><p><strong>Step 1</strong>  Install prerequisites - wget and latest pip.</p>
<p>Installing <em>MXNet</em> with pip requires a latest version of <code class="docutils literal"><span class="pre">pip</span></code>. Install the latest version of <code class="docutils literal"><span class="pre">pip</span></code> by issuing the following command in the terminal.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get update
$ sudo apt-get install -y wget python gcc
$ wget https://bootstrap.pypa.io/get-pip.py <span class="o">&amp;&amp;</span> sudo python get-pip.py
</pre></div>
</div>
<p><strong>Step 2</strong> Install MXNet with OpenBLAS acceleration.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install mxnet --pre
</pre></div>
</div>
<p><strong>Step 3</strong>  Install <a class="reference external" href="http://www.graphviz.org/">Graphviz</a>. (Optional, needed for graph visualization using <code class="docutils literal"><span class="pre">mxnet.viz</span></code> package).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>sudo apt-get install graphviz
pip install graphviz
</pre></div>
</div>
<p><strong>Step 4</strong>  Validate the installation by running simple MXNet code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
<p><strong>Experimental Choice</strong> If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install mxnet-mkl --pre
</pre></div>
</div>
</div> <!-- End of pip --><div class="virtualenv">
<br/><p><strong>Step 1</strong>  Install virtualenv for Ubuntu.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get update
$ sudo apt-get install -y python-dev python-virtualenv
</pre></div>
</div>
<p><strong>Step 2</strong>  Create and activate virtualenv environment for MXNet.</p>
<p>Following command creates a virtualenv environment at <code class="docutils literal"><span class="pre">~/mxnet</span></code> directory. However, you can choose any directory by replacing <code class="docutils literal"><span class="pre">~/mxnet</span></code> with a directory of your choice.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ virtualenv --system-site-packages ~/mxnet
</pre></div>
</div>
<p>Activate the virtualenv environment created for <em>MXNet</em>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ <span class="nb">source</span> ~/mxnet/bin/activate
</pre></div>
</div>
<p>After activating the environment, you should see the prompt as below.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="o">(</span>mxnet<span class="o">)</span>$
</pre></div>
</div>
<p><strong>Step 3</strong>  Install MXNet in the active virtualenv environment.</p>
<p>Installing <em>MXNet</em> with pip requires a latest version of <code class="docutils literal"><span class="pre">pip</span></code>. Install the latest version of <code class="docutils literal"><span class="pre">pip</span></code> by issuing the following command.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install --upgrade pip
</pre></div>
</div>
<p>Install <em>MXNet</em> with OpenBLAS acceleration.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install mxnet --pre
</pre></div>
</div>
<p><strong>Step 4</strong>  Install <a class="reference external" href="http://www.graphviz.org/">Graphviz</a>. (Optional, needed for graph visualization using <code class="docutils literal"><span class="pre">mxnet.viz</span></code> package).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>sudo apt-get install graphviz
pip install graphviz
</pre></div>
</div>
<p><strong>Step 5</strong>  Validate the installation by running simple <em>MXNet</em> code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
<p><strong>Note</strong>  You can read more about virtualenv <a class="reference external" href="https://virtualenv.pypa.io/en/stable/userguide/">here</a>.</p>
</div> <!-- END of virtualenv --><div class="docker">
<br/><p>Docker images with <em>MXNet</em> are available at <a class="reference external" href="https://hub.docker.com/r/mxnet/">Docker Hub</a>.</p>
<p><strong>Step 1</strong>  Install Docker on your machine by following the <a class="reference external" href="https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository">docker installation instructions</a>.</p>
<p><em>Note</em> - You can install Community Edition (CE) to get started with <em>MXNet</em>.</p>
<p><strong>Step 2</strong> [Optional] Post installation steps to manage Docker as a non-root user.</p>
<p>Follow the four steps in this <a class="reference external" href="https://docs.docker.com/engine/installation/linux/linux-postinstall/#manage-docker-as-a-non-root-user">docker documentation</a> to allow managing docker containers without <em>sudo</em>.</p>
<p>If you skip this step, you need to use <em>sudo</em> each time you invoke Docker.</p>
<p><strong>Step 3</strong> Pull the MXNet docker image.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ docker pull mxnet/python <span class="c1"># Use sudo if you skip Step 2</span>
</pre></div>
</div>
<p>You can list docker images to see if mxnet/python docker image pull was successful.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ docker images <span class="c1"># Use sudo if you skip Step 2</span>

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mxnet/python        latest              00d026968b3c        <span class="m">3</span> weeks ago         <span class="m">1</span>.41 GB
</pre></div>
</div>
<p><strong>Step 4</strong> Validate the installation by running simple MXNet code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
</div> <!-- END of docker --><div class="build-from-source">
<br/><p>Building <em>MXNet</em> from source is a 2 step process.</p>
<ol class="simple">
<li>Build the <em>MXNet</em> core shared library, <code class="docutils literal"><span class="pre">libmxnet.so</span></code>, from the C++ sources.</li>
<li>Build the language specific bindings. Example - Python bindings, Scala bindings.</li>
</ol>
<p><strong>Minimum Requirements</strong></p>
<ol class="simple">
<li><a class="reference external" href="https://gcc.gnu.org/gcc-4.8/">GCC 4.8</a> or later to compile C++ 11.</li>
<li><a class="reference external" href="https://www.gnu.org/software/make/">GNU Make</a></li>
</ol>
<p><br/></p>
<p><strong>Build the MXNet core shared library</strong></p>
<p><strong>Step 1</strong> Install build tools and git.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get update
$ sudo apt-get install -y build-essential git
</pre></div>
</div>
<p><strong>Step 2</strong> Install OpenBLAS.</p>
<p><em>MXNet</em> uses <a class="reference external" href="https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms">BLAS</a> and <a class="reference external" href="https://en.wikipedia.org/wiki/LAPACK">LAPACK</a> libraries for accelerated numerical computations on CPU machine. There are several flavors of BLAS/LAPACK libraries - <a class="reference external" href="http://www.openblas.net/">OpenBLAS</a>, <a class="reference external" href="http://math-atlas.sourceforge.net/">ATLAS</a> and <a class="reference external" href="https://software.intel.com/en-us/intel-mkl">MKL</a>. In this step we install OpenBLAS. You can choose to install ATLAS or MKL.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y libopenblas-dev liblapack-dev
</pre></div>
</div>
<p><strong>Step 3</strong> Install OpenCV.</p>
<p><em>MXNet</em> uses <a class="reference external" href="http://opencv.org/">OpenCV</a> for efficient image loading and augmentation operations.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y libopencv-dev
</pre></div>
</div>
<p><strong>Step 4</strong> Download MXNet sources and build MXNet core shared library. You can clone the repository as described in the following code block, or you may try the <a href="download.html">download links</a> for your desired MXNet version.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ git clone --recursive https://github.com/apache/incubator-mxnet
$ <span class="nb">cd</span> incubator-mxnet
$ make -j <span class="k">$(</span>nproc<span class="k">)</span> <span class="nv">USE_OPENCV</span><span class="o">=</span><span class="m">1</span> <span class="nv">USE_BLAS</span><span class="o">=</span>openblas
</pre></div>
</div>
<p><em>Note</em> - USE_OPENCV and USE_BLAS are make file flags to set compilation options to use OpenCV and BLAS library. You can explore and use more compilation options in <code class="docutils literal"><span class="pre">make/config.mk</span></code>.</p>
<p><br/></p>
<p><strong>Build the MXNet Python binding</strong></p>
<p><strong>Step 1</strong> Install prerequisites - python, setup-tools, python-pip and libfortran (required for Numpy).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y python-dev python-setuptools python-pip libgfortran3
</pre></div>
</div>
<p><strong>Step 2</strong> Install the MXNet Python binding.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ <span class="nb">cd</span> python
$ pip install --upgrade pip
$ pip install -e .
</pre></div>
</div>
<p>Note that the <code class="docutils literal"><span class="pre">-e</span></code> flag is optional. It is equivalent to <code class="docutils literal"><span class="pre">--editable</span></code> and means that if you edit the source files, these changes will be reflected in the package installed.</p>
<p><strong>Step 3</strong>  Install <a class="reference external" href="http://www.graphviz.org/">Graphviz</a>. (Optional, needed for graph visualization using <code class="docutils literal"><span class="pre">mxnet.viz</span></code> package).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>sudo apt-get install graphviz
pip install graphviz
</pre></div>
</div>
<p><strong>Step 4</strong> Validate the installation by running simple MXNet code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
</div><!-- END of build from source -->
</div><!-- END of CPU -->
<!-- END - Linux Python CPU Installation Instructions --><!-- START - Linux Python GPU Installation Instructions --><div class="gpu"><p>The following installation instructions have been tested on Ubuntu 14.04 and 16.04.</p>
<p><strong>Prerequisites</strong></p>
<p>Install the following NVIDIA libraries to setup <em>MXNet</em> with GPU support:</p>
<ol class="simple">
<li>Install CUDA 9.0 following the NVIDIA&#8217;s <a class="reference external" href="http://docs.nvidia.com/cuda/cuda-installation-guide-linux/">installation guide</a>.</li>
<li>Install cuDNN 7 for CUDA 9.0 following the NVIDIA&#8217;s <a class="reference external" href="https://developer.nvidia.com/cudnn">installation guide</a>. You may need to register with NVIDIA for downloading the cuDNN library.</li>
</ol>
<p><strong>Note:</strong> Make sure to add CUDA install path to <code class="docutils literal"><span class="pre">LD_LIBRARY_PATH</span></code>.</p>
<p>Example - <em>export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH</em></p>
<div class="pip">
<br/><p><strong>Step 1</strong>  Install prerequisites - wget and latest pip.</p>
<p>Installing <em>MXNet</em> with pip requires a latest version of <code class="docutils literal"><span class="pre">pip</span></code>. Install the latest version of <code class="docutils literal"><span class="pre">pip</span></code> by issuing the following command in the terminal.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get update
$ sudo apt-get install -y wget python
$ wget https://bootstrap.pypa.io/get-pip.py <span class="o">&amp;&amp;</span> sudo python get-pip.py
</pre></div>
</div>
<p><strong>Step 2</strong>  Install <em>MXNet</em> with GPU support using CUDA 9.0</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install mxnet-cu90 --pre
</pre></div>
</div>
<p><strong>Step 3</strong>  Install <a class="reference external" href="http://www.graphviz.org/">Graphviz</a>. (Optional, needed for graph visualization using <code class="docutils literal"><span class="pre">mxnet.viz</span></code> package).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>sudo apt-get install graphviz
pip install graphviz
</pre></div>
</div>
<p><strong>Step 4</strong>  Validate the installation by running simple MXNet code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
<p><strong>Experimental Choice</strong> If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install mxnet-cu90mkl --pre
</pre></div>
</div>
</div> <!-- END of pip --><div class="virtualenv"><p><br/></p>
<p><strong>Step 1</strong>  Install virtualenv for Ubuntu.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get update
$ sudo apt-get install -y python-dev python-virtualenv
</pre></div>
</div>
<p><strong>Step 2</strong>  Create and activate virtualenv environment for MXNet.</p>
<p>Following command creates a virtualenv environment at <code class="docutils literal"><span class="pre">~/mxnet</span></code> directory. However, you can choose any directory by replacing <code class="docutils literal"><span class="pre">~/mxnet</span></code> with a directory of your choice.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ virtualenv --system-site-packages ~/mxnet
</pre></div>
</div>
<p>Activate the virtualenv environment created for <em>MXNet</em>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ <span class="nb">source</span> ~/mxnet/bin/activate
</pre></div>
</div>
<p>After activating the environment, you should see the prompt as below.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="o">(</span>mxnet<span class="o">)</span>$
</pre></div>
</div>
<p><strong>Step 3</strong>  Install MXNet in the active virtualenv environment.</p>
<p>Installing <em>MXNet</em> with pip requires a latest version of <code class="docutils literal"><span class="pre">pip</span></code>. Install the latest version of <code class="docutils literal"><span class="pre">pip</span></code> by issuing the following command.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="o">(</span>mxnet<span class="o">)</span>$ pip install --upgrade pip
</pre></div>
</div>
<p>Install <em>MXNet</em> with GPU support using CUDA 9.0.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="o">(</span>mxnet<span class="o">)</span>$ pip install mxnet-cu90 --pre
</pre></div>
</div>
<p><strong>Step 4</strong>  Install <a class="reference external" href="http://www.graphviz.org/">Graphviz</a>. (Optional, needed for graph visualization using <code class="docutils literal"><span class="pre">mxnet.viz</span></code> package).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>sudo apt-get install graphviz
pip install graphviz
</pre></div>
</div>
<p><strong>Step 5</strong>  Validate the installation by running simple <em>MXNet</em> code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
<p><strong>Note</strong>  You can read more about virtualenv <a class="reference external" href="https://virtualenv.pypa.io/en/stable/userguide/">here</a>.</p>
</div> <!-- END of virtualenv --><div class="docker"><p><br/></p>
<p>Docker images with <em>MXNet</em> are available at <a class="reference external" href="https://hub.docker.com/r/mxnet/">Docker Hub</a>.</p>
<p><strong>Step 1</strong>  Install Docker on your machine by following the <a class="reference external" href="https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository">docker installation instructions</a>.</p>
<p><em>Note</em> - You can install Community Edition (CE) to get started with <em>MXNet</em>.</p>
<p><strong>Step 2</strong> [Optional] Post installation steps to manage Docker as a non-root user.</p>
<p>Follow the four steps in this <a class="reference external" href="https://docs.docker.com/engine/installation/linux/linux-postinstall/#manage-docker-as-a-non-root-user">docker documentation</a> to allow managing docker containers without <em>sudo</em>.</p>
<p>If you skip this step, you need to use <em>sudo</em> each time you invoke Docker.</p>
<p><strong>Step 3</strong> Install <em>nvidia-docker-plugin</em> following the <a class="reference external" href="https://github.com/NVIDIA/nvidia-docker/wiki/Installation">installation instructions</a>. <em>nvidia-docker-plugin</em> is required to enable the usage of GPUs from the docker containers.</p>
<p><strong>Step 4</strong> Pull the MXNet docker image.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ docker pull mxnet/python:gpu <span class="c1"># Use sudo if you skip Step 2</span>
</pre></div>
</div>
<p>You can list docker images to see if mxnet/python docker image pull was successful.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ docker images <span class="c1"># Use sudo if you skip Step 2</span>

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mxnet/python        gpu                 493b2683c269        <span class="m">3</span> weeks ago         <span class="m">4</span>.77 GB
</pre></div>
</div>
<p><strong>Step 5</strong> Validate the installation by running simple MXNet code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
</div> <!-- END of docker --><div class="build-from-source"><p><br/></p>
<p>Building <em>MXNet</em> from source is a 2 step process.</p>
<ol class="simple">
<li>Build the <em>MXNet</em> core shared library, <code class="docutils literal"><span class="pre">libmxnet.so</span></code>, from the C++ sources.</li>
<li>Build the language specific bindings. Example - Python bindings, Scala bindings.</li>
</ol>
<p><strong>Minimum Requirements</strong></p>
<ol class="simple">
<li><a class="reference external" href="https://gcc.gnu.org/gcc-4.8/">GCC 4.8</a> or later to compile C++ 11.</li>
<li><a class="reference external" href="https://www.gnu.org/software/make/">GNU Make</a></li>
</ol>
<p><br/></p>
<p><strong>Build the MXNet core shared library</strong></p>
<p><strong>Step 1</strong> Install build tools and git.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get update
$ sudo apt-get install -y build-essential git
</pre></div>
</div>
<p><strong>Step 2</strong> Install OpenBLAS.</p>
<p><em>MXNet</em> uses <a class="reference external" href="https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms">BLAS</a> and <a class="reference external" href="https://en.wikipedia.org/wiki/LAPACK">LAPACK</a> libraries for accelerated numerical computations on CPU machine. There are several flavors of BLAS/LAPACK libraries - <a class="reference external" href="http://www.openblas.net/">OpenBLAS</a>, <a class="reference external" href="http://math-atlas.sourceforge.net/">ATLAS</a> and <a class="reference external" href="https://software.intel.com/en-us/intel-mkl">MKL</a>. In this step we install OpenBLAS. You can choose to install ATLAS or MKL.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y libopenblas-dev liblapack-dev
</pre></div>
</div>
<p><strong>Step 3</strong> Install OpenCV.</p>
<p><em>MXNet</em> uses <a class="reference external" href="http://opencv.org/">OpenCV</a> for efficient image loading and augmentation operations.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y libopencv-dev
</pre></div>
</div>
<p><strong>Step 4</strong> Download MXNet sources and build MXNet core shared library. You can clone the repository as described in the following code block, or you may try the <a href="download.html">download links</a> for your desired MXNet version.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ git clone --recursive https://github.com/apache/incubator-mxnet
$ <span class="nb">cd</span> incubator-mxnet
$ make -j <span class="k">$(</span>nproc<span class="k">)</span> <span class="nv">USE_OPENCV</span><span class="o">=</span><span class="m">1</span> <span class="nv">USE_BLAS</span><span class="o">=</span>openblas <span class="nv">USE_CUDA</span><span class="o">=</span><span class="m">1</span> <span class="nv">USE_CUDA_PATH</span><span class="o">=</span>/usr/local/cuda <span class="nv">USE_CUDNN</span><span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
<p><em>Note</em> - USE_OPENCV, USE_BLAS, USE_CUDA, USE_CUDA_PATH AND USE_CUDNN are make file flags to set compilation options to use OpenCV, OpenBLAS, CUDA and cuDNN libraries. You can explore and use more compilation options in <code class="docutils literal"><span class="pre">make/config.mk</span></code>. Make sure to set USE_CUDA_PATH to right CUDA installation path. In most cases it is - <em>/usr/local/cuda</em>.</p>
<p><br/></p>
<p><strong>Install the MXNet Python binding</strong></p>
<p><strong>Step 1</strong> Install prerequisites - python, setup-tools, python-pip and libfortran (required for Numpy)..</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y python-dev python-setuptools python-pip libgfortran3
</pre></div>
</div>
<p><strong>Step 2</strong> Install the MXNet Python binding.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ <span class="nb">cd</span> python
$ pip install --upgrade pip
$ pip install -e .
</pre></div>
</div>
<p>Note that the <code class="docutils literal"><span class="pre">-e</span></code> flag is optional. It is equivalent to <code class="docutils literal"><span class="pre">--editable</span></code> and means that if you edit the source files, these changes will be reflected in the package installed.</p>
<p><strong>Step 3</strong>  Install <a class="reference external" href="http://www.graphviz.org/">Graphviz</a>. (Optional, needed for graph visualization using <code class="docutils literal"><span class="pre">mxnet.viz</span></code> package).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>sudo apt-get install graphviz
pip install graphviz
</pre></div>
</div>
<p><strong>Step 4</strong> Validate the installation by running simple MXNet code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
</div> <!-- END of build from source -->
</div> <!-- END of GPU -->
</div> <!-- END of Python -->
-<!-- END - Linux Python GPU Installation Instructions --><div class="r">
<div class="cpu"><p><br/></p>
<p>Building <em>MXNet</em> from source is a 2 step process.</p>
<ol class="simple">
<li>Build the <em>MXNet</em> core shared library, <code class="docutils literal"><span class="pre">libmxnet.so</span></code>, from the C++ sources.</li>
<li>Build the language specific bindings.</li>
</ol>
<p><strong>Minimum Requirements</strong></p>
<ol class="simple">
<li><a class="reference external" href="https://gcc.gnu.org/gcc-4.8/">GCC 4.8</a> or later to compile C++ 11.</li>
<li><a class="reference external" href="https://www.gnu.org/software/make/">GNU Make</a></li>
</ol>
<p><br/></p>
<p><strong>Build the MXNet core shared library</strong></p>
<p><strong>Step 1</strong> Install build tools and git.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get update
$ sudo apt-get install -y build-essential git
</pre></div>
</div>
<p><strong>Step 2</strong> Install OpenBLAS.</p>
<p><em>MXNet</em> uses <a class="reference external" href="https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms">BLAS</a> and <a class="reference external" href="https://en.wikipedia.org/wiki/LAPACK">LAPACK</a> libraries for accelerated numerical computations on CPU machine. There are several flavors of BLAS/LAPACK libraries - <a class="reference external" href="http://www.openblas.net/">OpenBLAS</a>, <a class="reference external" href="http://math-atlas.sourceforge.net/">ATLAS</a> and <a class="reference external" href="https://software.intel.com/en-us/intel-mkl">MKL</a>. In this step we install OpenBLAS. You can choose to install ATLAS or MKL.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y libopenblas-dev liblapack-dev
</pre></div>
</div>
<p><strong>Step 3</strong> Install OpenCV.</p>
<p><em>MXNet</em> uses <a class="reference external" href="http://opencv.org/">OpenCV</a> for efficient image loading and augmentation operations.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y libopencv-dev
</pre></div>
</div>
<p><strong>Step 4</strong> Download MXNet sources and build MXNet core shared library. You can clone the repository as described in the following code block, or you may try the <a href="download.html">download links</a> for your desired MXNet version.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ git clone --recursive https://github.com/apache/incubator-mxnet
$ <span class="nb">cd</span> incubator-mxnet
$ make -j <span class="k">$(</span>nproc<span class="k">)</span> <span class="nv">USE_OPENCV</span><span class="o">=</span><span class="m">1</span> <span class="nv">USE_BLAS</span><span class="o">=</span>openblas
</pre></div>
</div>
<p><em>Note</em> - USE_OPENCV and USE_BLAS are make file flags to set compilation options to use OpenCV and BLAS library. You can explore and use more compilation options in <code class="docutils literal"><span class="pre">make/config.mk</span></code>.</p>
<p><br/></p>
<p><strong>Build and install the MXNet R binding</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make rpkg
$ R CMD INSTALL mxnet_current_r.tar.gz
</pre></div>
</div>
</div> <!-- END of CPU --><div class="gpu"><p>The following installation instructions have been tested on Ubuntu 14.04 and 16.04.</p>
<p><strong>Prerequisites</strong></p>
<p>Install the following NVIDIA libraries to setup <em>MXNet</em> with GPU support:</p>
<ol class="simple">
<li>Install CUDA 9.0 following the NVIDIA&#8217;s <a class="reference external" href="http://docs.nvidia.com/cuda/cuda-installation-guide-linux/">installation guide</a>.</li>
<li>Install cuDNN 7 for CUDA 9.0 following the NVIDIA&#8217;s <a class="reference external" href="https://developer.nvidia.com/cudnn">installation guide</a>. You may need to register with NVIDIA for downloading the cuDNN library.</li>
</ol>
<p><strong>Note:</strong> Make sure to add CUDA install path to <code class="docutils literal"><span class="pre">LD_LIBRARY_PATH</span></code>.</p>
<p>Example - <em>export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH</em></p>
<p><br/></p>
<p>Building <em>MXNet</em> from source is a 2 step process.</p>
<ol class="simple">
<li>Build the <em>MXNet</em> core shared library, <code class="docutils literal"><span class="pre">libmxnet.so</span></code>, from the C++ sources.</li>
<li>Build the language specific bindings.</li>
</ol>
<p><strong>Minimum Requirements</strong></p>
<ol class="simple">
<li><a class="reference external" href="https://gcc.gnu.org/gcc-4.8/">GCC 4.8</a> or later to compile C++ 11.</li>
<li><a class="reference external" href="https://www.gnu.org/software/make/">GNU Make</a></li>
</ol>
<p><br/></p>
<p><strong>Build the MXNet core shared library</strong></p>
<p><strong>Step 1</strong> Install build tools and git.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get update
$ sudo apt-get install -y build-essential git
</pre></div>
</div>
<p><strong>Step 2</strong> Install OpenBLAS.</p>
<p><em>MXNet</em> uses <a class="reference external" href="https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms">BLAS</a> and <a class="reference external" href="https://en.wikipedia.org/wiki/LAPACK">LAPACK</a> libraries for accelerated numerical computations on CPU machine. There are several flavors of BLAS/LAPACK libraries - <a class="reference external" href="http://www.openblas.net/">OpenBLAS</a>, <a class="reference external" href="http://math-atlas.sourceforge.net/">ATLAS</a> and <a class="reference external" href="https://software.intel.com/en-us/intel-mkl">MKL</a>. In this step we install OpenBLAS. You can choose to install ATLAS or MKL.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y libopenblas-dev liblapack-dev
</pre></div>
</div>
<p><strong>Step 3</strong> Install OpenCV.</p>
<p><em>MXNet</em> uses <a class="reference external" href="http://opencv.org/">OpenCV</a> for efficient image loading and augmentation operations.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y libopencv-dev
</pre></div>
</div>
<p><strong>Step 4</strong> Download MXNet sources and build MXNet core shared library. You can clone the repository as described in the following code block, or you may try the <a href="download.html">download links</a> for your desired MXNet version.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ git clone --recursive https://github.com/apache/incubator-mxnet
$ <span class="nb">cd</span> incubator-mxnet
$ make -j <span class="k">$(</span>nproc<span class="k">)</span> <span class="nv">USE_OPENCV</span><span class="o">=</span><span class="m">1</span> <span class="nv">USE_BLAS</span><span class="o">=</span>openblas <span class="nv">USE_CUDA</span><span class="o">=</span><span class="m">1</span> <span class="nv">USE_CUDA_PATH</span><span class="o">=</span>/usr/local/cuda <span class="nv">USE_CUDNN</span><span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
<p><em>Note</em> - USE_OPENCV, USE_BLAS, USE_CUDA, USE_CUDA_PATH AND USE_CUDNN are make file flags to set compilation options to use OpenCV, OpenBLAS, CUDA and cuDNN libraries. You can explore and use more compilation options in <code class="docutils literal"><span class="pre">make/config.mk</span></code>. Make sure to set USE_CUDA_PATH to right CUDA installation path. In most cases it is - <em>/usr/local/cuda</em>.</p>
<p><br/></p>
<p><strong>Build and install the MXNet R binding</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make rpkg
$ R CMD INSTALL mxnet_current_r.tar.gz
</pre></div>
</div>
</div> <!-- END of GPU -->
</div> <!-- END of R --><div class="scala julia perl">
<div class="cpu gpu"><p>Follow the installation instructions <a class="reference internal" href="ubuntu_setup.html"><span class="doc">in this guide</span></a> to set up MXNet.</p>
</div> <!-- End of cpu gpu -->
</div> <!-- End of scala julia perl -->
</div> <!-- END - Linux --><!-- START - MacOS Python CPU Installation Instructions --><div class="macos">
<div class="python">
<div class="cpu"><p>The following installation instructions have been tested on OSX Sierra and El Capitan.</p>
<div class="pip">
<br/><p><strong>Step 1</strong>  Install prerequisites - Homebrew, python development tools.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># Install Homebrew</span>
$ /usr/bin/ruby -e <span class="s2">&quot;</span><span class="k">$(</span>curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install<span class="k">)</span><span class="s2">&quot;</span>
$ <span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>/usr/local/bin:/usr/local/sbin:<span class="nv">$PATH</span>

<span class="c1"># Install python development tools - python2.7, pip, python-setuptools</span>
$ brew install python
</pre></div>
</div>
<p><strong>Step 2</strong> Install MXNet with OpenBLAS acceleration.</p>
<p>Installing <em>MXNet</em> with pip requires a latest version of <code class="docutils literal"><span class="pre">pip</span></code>. Install the latest version of <code class="docutils literal"><span class="pre">pip</span></code> by issuing the following command.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install --upgrade pip
$ pip install --upgrade setuptools
</pre></div>
</div>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install mxnet --pre
</pre></div>
</div>
<p><strong>Step 3</strong>  Install <a class="reference external" href="http://www.graphviz.org/">Graphviz</a>. (Optional, needed for graph visualization using <code class="docutils literal"><span class="pre">mxnet.viz</span></code> package).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ brew install graphviz
$ pip install graphviz
</pre></div>
</div>
<p><strong>Step 4</strong>  Validate the installation by running simple MXNet code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
</div> <!-- END of pip --><div class="virtualenv">
<br/><p><strong>Step 1</strong>  Install prerequisites - Homebrew, python development tools.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># Install Homebrew</span>
$ /usr/bin/ruby -e <span class="s2">&quot;</span><span class="k">$(</span>curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install<span class="k">)</span><span class="s2">&quot;</span>
$ <span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>/usr/local/bin:/usr/local/sbin:<span class="nv">$PATH</span>

<span class="c1"># Install python development tools - python2.7, pip, python-setuptools</span>
$ brew install python
</pre></div>
</div>
<p><strong>Step 2</strong>  Install virtualenv for macOS.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install virtualenv
</pre></div>
</div>
<p><strong>Step 3</strong>  Create and activate virtualenv environment for MXNet.</p>
<p>Following command creates a virtualenv environment at <code class="docutils literal"><span class="pre">~/mxnet</span></code> directory. However, you can choose any directory by replacing <code class="docutils literal"><span class="pre">~/mxnet</span></code> with a directory of your choice.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ virtualenv --system-site-packages ~/mxnet
</pre></div>
</div>
<p>Activate the virtualenv environment created for <em>MXNet</em>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ <span class="nb">source</span> ~/mxnet/bin/activate
</pre></div>
</div>
<p>After activating the environment, you should see the prompt as below.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="o">(</span>mxnet<span class="o">)</span>$
</pre></div>
</div>
<p><strong>Step 4</strong>  Install MXNet in the active virtualenv environment.</p>
<p>Installing <em>MXNet</em> with pip requires a latest version of <code class="docutils literal"><span class="pre">pip</span></code>. Install the latest version of <code class="docutils literal"><span class="pre">pip</span></code> by issuing the following command.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="o">(</span>mxnet<span class="o">)</span>$ pip install --upgrade pip
<span class="o">(</span>mxnet<span class="o">)</span>$ pip install --upgrade setuptools
</pre></div>
</div>
<p>Install <em>MXNet</em> with OpenBLAS acceleration.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="o">(</span>mxnet<span class="o">)</span>$ pip install mxnet --pre
</pre></div>
</div>
<p><strong>Step 5</strong>  Install <a class="reference external" href="http://www.graphviz.org/">Graphviz</a>. (Optional, needed for graph visualization using <code class="docutils literal"><span class="pre">mxnet.viz</span></code> package).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ brew install graphviz
<span class="o">(</span>mxnet<span class="o">)</span>$ pip install graphviz
</pre></div>
</div>
<p><strong>Step 6</strong>  Validate the installation by running simple <em>MXNet</em> code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
<p><strong>Note</strong>  You can read more about virtualenv <a class="reference external" href="https://virtualenv.pypa.io/en/stable/userguide/">here</a>.</p>
</div> <!-- End of virtualenv --><div class="docker">
<br/><p>Docker images with <em>MXNet</em> are available at <a class="reference external" href="https://hub.docker.com/r/mxnet/">Docker Hub</a>.</p>
<p><strong>Step 1</strong>  Install Docker on your machine by following the <a class="reference external" href="https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-for-mac">docker installation instructions</a>.</p>
<p><em>Note</em> - You can install Community Edition (CE) to get started with <em>MXNet</em>.</p>
<p><strong>Step 2</strong> Pull the MXNet docker image.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ docker pull mxnet/python
</pre></div>
</div>
<p>You can list docker images to see if mxnet/python docker image pull was successful.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mxnet/python        latest              00d026968b3c        <span class="m">3</span> weeks ago         <span class="m">1</span>.41 GB
</pre></div>
</div>
<p><strong>Step 4</strong> Validate the installation by running simple MXNet code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
</div> <!-- END of docker --><div class="build-from-source">
<br/><p><strong>Prerequisites</strong></p>
<p>If not already installed, <a class="reference external" href="https://developer.apple.com/xcode/">download and install Xcode</a> (or <a class="reference external" href="https://itunes.apple.com/us/app/xcode/id497799835">insall it from the App Store</a>) for macOS. <a class="reference external" href="https://en.wikipedia.org/wiki/Xcode">Xcode</a> is an integrated development environment for macOS containing a suite of software development tools like C/C++ compilers, BLAS library and more.</p>
<p><br/></p>
<p>Building <em>MXNet</em> from source is a 2 step process.</p>
<ol class="simple">
<li>Build the <em>MXNet</em> core shared library, <code class="docutils literal"><span class="pre">libmxnet.so</span></code>, from the C++ sources.</li>
<li>Build the language specific bindings. Example - Python bindings, Scala bindings.</li>
</ol>
<p>Make sure you have installed Xcode before proceeding further.</p>
<p><br/></p>
<p>All the instructions to build <em>MXNet</em> core shared library and <em>MXNet</em> Python bindings are compiled as one helper <em>bash</em> script. You can use <a class="reference external" href="https://raw.githubusercontent.com/dmlc/mxnet/master/setup-utils/install-mxnet-osx-python.sh">this bash script</a> to build <em>MXNet</em> for Python, from source, on macOS.</p>
<p><strong>Step 1</strong> Download the bash script for building MXNet from source.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ curl -O https://raw.githubusercontent.com/dmlc/mxnet/master/setup-utils/install-mxnet-osx-python.sh
</pre></div>
</div>
<p><strong>Step 2</strong> Run the script to get latest MXNet source and build.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># Make the script executable</span>
$ chmod <span class="m">744</span> install-mxnet-osx-python.sh

<span class="c1"># Run the script. It takes around 5 mins.</span>
$ bash install-mxnet-osx-python.sh
</pre></div>
</div>
<p><strong>Step 3</strong> Validate the installation by running simple MXNet code described <a class="reference external" href="#validate-mxnet-installation">here</a>.</p>
</div> <!-- END of build from source -->
</div> <!-- END of CPU --><!-- START - Mac OS Python GPU Installation Instructions -->
<div class="gpu">
<div class="pip virtualenv docker">
</br><p>Try the <strong>Build from Source</strong> option for now.</p>
</div><div class="build-from-source"><p><strong>Step 1</strong>  Install prerequisites - Homebrew, python development tools.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="c1"># Install Homebrew</span>
$ /usr/bin/ruby -e <span class="s2">&quot;</span><span class="k">$(</span>curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install<span class="k">)</span><span class="s2">&quot;</span>
$ <span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>/usr/local/bin:/usr/local/sbin:<span class="nv">$PATH</span>

<span class="c1"># Install python development tools - python2.7, pip, python-setuptools</span>
$ brew install python pkg-config graphviz
</pre></div>
</div>
<p><strong>Step 2</strong>  Install optional components - OpenCV</p>
<p>If you want to use OpenCV you should install it first, then build MXNet with the <code class="docutils literal"><span class="pre">USE_OPENCV=1</span></code> option in the later steps.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>brew tap homebrew/science
brew install opencv
</pre></div>
</div>
<p><strong>Step 3</strong>  Install CUDA and cuDNN</p>
<p>The following instructions are for CUDA 9.1 and cuDNN 7 for macOS 10.12+ and a CUDA-capable GPU. They summarize confirmed successful builds in <a class="reference external" href="https://github.com/apache/incubator-mxnet/issues/9217">#9217</a>.
Alternatively, you may follow the <a class="reference external" href="https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html">CUDA installation instructions for macOS</a>.</p>
<ol class="simple">
<li><a class="reference external" href="https://developer.apple.com/download/more/">Download Xcode 8.3.3 from Apple</a>. This is the version <a class="reference external" href="https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html">NVIDIA specifies in its instructions for macOS</a>. Unzip and rename to <code class="docutils literal"><span class="pre">Xcode8.3.3.app</span></code>.</li>
<li>Run <code class="docutils literal"><span class="pre">sudo</span> <span class="pre">xcode-select</span> <span class="pre">-s</span> <span class="pre">/Applications/Xcode8.3.3.app</span></code> or to wherever you have placed Xcode.</li>
<li>Run <code class="docutils literal"><span class="pre">xcode-select</span> <span class="pre">--install</span></code> to install all command line tools, compilers, etc.</li>
<li>Run <code class="docutils literal"><span class="pre">sudo</span> <span class="pre">xcodebuild</span> <span class="pre">-license</span> <span class="pre">accept</span></code> to accept Xcode&#8217;s licensing terms.</li>
<li>Install CUDA for macOS. Specific steps are provided in NVIDIA&#8217;s <a class="reference external" href="https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#installation">CUDA installation instructions</a>.</li>
<li><a class="reference external" href="http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#download-mac">Download</a> and <a class="reference external" href="http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installmac">install</a> cuDNN for macOS. You will need to <a class="reference external" href="https://developer.nvidia.com/accelerated-computing-developer">create a free developer account</a> with NVIDIA prior to getting the download link.</li>
</ol>
<p><strong>Step 4</strong>  Build MXNet</p>
<ol>
<li><p class="first">Run <code class="docutils literal"><span class="pre">git</span> <span class="pre">clone</span> <span class="pre">--recursive</span> <span class="pre">https://github.com/apache/incubator-mxnet.git</span> <span class="pre">mxnet</span></code> to get the latest version.</p>
</li>
<li><p class="first">Run <code class="docutils literal"><span class="pre">cd</span> <span class="pre">mxnet</span></code>.</p>
</li>
<li><p class="first">Edit the <code class="docutils literal"><span class="pre">make/osx.mk</span></code> file to set the following parameters:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">USE_CUDA</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">USE_CUDA_PATH</span> <span class="o">=</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span><span class="o">/</span><span class="n">cuda</span>
<span class="n">USE_CUDNN</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">USE_OPENCV</span> <span class="o">=</span> <span class="mi">0</span>   <span class="c1"># set to 1 if you want to build with OpenCV</span>
</pre></div>
</div>
</li>
<li><p class="first">Copy the <code class="docutils literal"><span class="pre">make/osx.mk</span></code> to <code class="docutils literal"><span class="pre">config.mk</span></code></p>
</li>
<li><p class="first">Run <code class="docutils literal"><span class="pre">make</span></code>. If you previously attempted to compile you might want to do <code class="docutils literal"><span class="pre">make</span> <span class="pre">clean_all</span></code> first. You can also run <code class="docutils literal"><span class="pre">make</span> <span class="pre">-j</span></code> with the number of processors you have to compile with multithreading. There&#8217;ll be plenty of warnings, but there should be no errors.</p>
</li>
<li><p class="first">Once finished, you should have a file called <code class="docutils literal"><span class="pre">libmxnet.so</span></code> in <code class="docutils literal"><span class="pre">lib/</span></code>.</p>
</li>
<li><p class="first">Do <code class="docutils literal"><span class="pre">cd</span> <span class="pre">python</span></code>.</p>
</li>
<li><p class="first">Run <code class="docutils literal"><span class="pre">sudo</span> <span class="pre">pip</span> <span class="pre">install</span> <span class="pre">-e</span> <span class="pre">.</span></code> <strong>Note</strong>: the <code class="docutils literal"><span class="pre">.</span></code> is part of the command.</p>
</li>
</ol>
</div> <!-- END of build from source -->
</div> <!-- END of GPU -->
</div> <!-- END of Python --><!-- START - MacOS R CPU Installation Instructions --><div class="r">
<div class="cpu"><p>The CPU version of MXNet R package can be installed in R like other packages</p>
<div class="highlight-r"><div class="highlight"><pre><span></span>cran <span class="o">&lt;-</span> <span class="kp">getOption</span><span class="p">(</span><span class="s">&quot;repos&quot;</span><span class="p">)</span>
cran<span class="p">[</span><span class="s">&quot;dmlc&quot;</span><span class="p">]</span> <span class="o">&lt;-</span> <span class="s">&quot;https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/&quot;</span>
<span class="kp">options</span><span class="p">(</span>repos <span class="o">=</span> cran<span class="p">)</span>
install.packages<span class="p">(</span><span class="s">&quot;mxnet&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div> <!-- END of CPU --><div class="gpu"><p>Will be available soon.</p>
</div> <!-- END of GPU -->
</div> <!-- END of R --><div class="scala julia perl">
<div class="cpu gpu"><p>Follow the installation instructions <a class="reference internal" href="osx_setup.html"><span class="doc">in this guide</span></a> to set up MXNet.</p>
</div> <!-- End of cpu gpu -->
</div> <!-- End of scala julia perl -->
</div> <!-- END - Mac OS --><div class="windows">
<div class="python">
<div class="cpu">
<div class="pip"><p><br/></p>
<p><strong>Step 1</strong>  Install Python.</p>
<p><a class="reference external" href="https://www.anaconda.com/download/">Anaconda</a> is recommended.</p>
<p><strong>Step 2</strong>  Install <em>MXNet</em>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install mxnet --pre
</pre></div>
</div>
</div> <!-- End of pip --><div class="virtualenv docker build-from-source"><p>Follow the installation instructions <a class="reference internal" href="windows_setup.html"><span class="doc">in this guide</span></a> to set up MXNet.</p>
</div> <!-- End of virtualenv docker build-from-source -->
</div> <!-- End of CPU --><div class="gpu">
<div class="pip"><p><br/></p>
<p><strong>Step 1</strong>  Install Python.</p>
<p><a class="reference external" href="https://www.anaconda.com/download/">Anaconda</a> is recommended.</p>
<p><strong>Step 2</strong>  Install <em>MXNet</em> with GPU support using CUDA 9.0.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ pip install mxnet-cu90 --pre
</pre></div>
</div>
<p>Refer to <a class="reference external" href="https://github.com/apache/incubator-mxnet/issues/8671">#8671</a> for status on CUDA 9.1 support.</p>
</div>
<div class="build-from-source">
<br/><p>We provide both options to build and install MXNet yourself using <a class="reference external" href="https://www.visualstudio.com/downloads/">Microsoft Visual Studio 2017</a>, and <a class="reference external" href="https://www.visualstudio.com/vs/older-downloads/">Microsoft Visual Studio 2015</a>.</p>
<p><strong>Option 1</strong></p>
<p>To build and install MXNet yourself using <a class="reference external" href="https://www.visualstudio.com/downloads/">Microsoft Visual Studio 2017</a>, you need the following dependencies. Install the required dependencies:</p>
<ol class="simple">
<li>If <a class="reference external" href="https://www.visualstudio.com/downloads/">Microsoft Visual Studio 2017</a> is not already installed, download and install it. You can download and install the free community edition.</li>
<li>Download and install <a class="reference external" href="https://cmake.org/files/v3.11/cmake-3.11.0-rc4-win64-x64.msi">CMake</a> if it is not already installed.</li>
<li>Download and install <a class="reference external" href="https://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.4.1/opencv-3.4.1-vc14_vc15.exe/download">OpenCV</a>.</li>
<li>Unzip the OpenCV package.</li>
<li>Set the environment variable <code class="docutils literal"><span class="pre">OpenCV_DIR</span></code> to point to the <code class="docutils literal"><span class="pre">OpenCV</span> <span class="pre">build</span> <span class="pre">directory</span></code> (e.g., <code class="docutils literal"><span class="pre">OpenCV_DIR</span> <span class="pre">=</span> <span class="pre">C:\utils\opencv\build</span></code>).</li>
<li>If you don’t have the Intel Math Kernel Library (MKL) installed, download and install <a class="reference external" href="https://sourceforge.net/projects/openblas/files/v0.2.20/OpenBLAS%200.2.20%20version.zip/download">OpenBlas</a>.</li>
<li>Set the environment variable <code class="docutils literal"><span class="pre">OpenBLAS_HOME</span></code> to point to the <code class="docutils literal"><span class="pre">OpenBLAS</span></code> directory that contains the <code class="docutils literal"><span class="pre">include</span></code> and <code class="docutils literal"><span class="pre">lib</span></code> directories (e.g., <code class="docutils literal"><span class="pre">OpenBLAS_HOME</span> <span class="pre">=</span> <span class="pre">C:\utils\OpenBLAS</span></code>).</li>
<li>Download and install CUDA: Install <a class="reference external" href="https://developer.nvidia.com/cuda-downloads?target_os=Windows&amp;target_arch=x86_64&amp;target_version=10&amp;target_type=exelocal">CUDA</a>, and Download the base installer (e.g., <code class="docutils literal"><span class="pre">cuda_9.1.85_win10.exe</span></code>).</li>
<li>Download and install cuDNN. To get access to the download link, register as an NVIDIA community user. Then Follow the <a class="reference external" href="http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#install-windows">link</a> to install the cuDNN.</li>
<li>Download and install <a class="reference external" href="https://git-for-windows.github.io/">git</a>.</li>
</ol>
<p>After you have installed all of the required dependencies, build the MXNet source code:</p>
<ol class="simple">
<li>Start <code class="docutils literal"><span class="pre">cmd</span></code> in windows.</li>
<li>Download the MXNet source code from GitHub by using following command:</li>
</ol>
<div class="highlight-r"><div class="highlight"><pre><span></span>cd C<span class="o">:</span>\
git clone https<span class="o">://</span>github.com<span class="o">/</span>apache<span class="o">/</span>incubator<span class="o">-</span>mxnet.git <span class="o">--</span>recursive
</pre></div>
</div>
<ol class="simple">
<li>Follow <a class="reference external" href="https://docs.microsoft.com/en-us/visualstudio/install/modify-visual-studio">this link</a> to modify <code class="docutils literal"><span class="pre">Individual</span> <span class="pre">components</span></code>, and check <code class="docutils literal"><span class="pre">VC++</span> <span class="pre">2017</span> <span class="pre">version</span> <span class="pre">15.4</span> <span class="pre">v14.11</span> <span class="pre">toolset</span></code>, and click <code class="docutils literal"><span class="pre">Modify</span></code>.</li>
<li>Change the version of the Visual studio 2017 to v14.11 using the following command (by default the VS2017 is installed in the following path):</li>
</ol>
<div class="highlight-r"><div class="highlight"><pre><span></span><span class="s">&quot;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat&quot;</span> <span class="o">-</span>vcvars_ver<span class="o">=</span><span class="m">14.11</span>
</pre></div>
</div>
<ol class="simple">
<li>Create a build dir using the following command and go to the directory, for example:</li>
</ol>
<div class="highlight-r"><div class="highlight"><pre><span></span>mkdir C<span class="o">:</span>\build
cd C<span class="o">:</span>\build
</pre></div>
</div>
<ol class="simple">
<li>CMake the MXNet source code by using following command:</li>
</ol>
<div class="highlight-r"><div class="highlight"><pre><span></span>cmake <span class="o">-</span>G <span class="s">&quot;Visual Studio 15 2017 Win64&quot;</span> <span class="o">-</span><span class="bp">T</span> cuda<span class="o">=</span><span class="m">9.1</span><span class="p">,</span>host<span class="o">=</span>x64 <span class="o">-</span>DUSE_CUDA<span class="o">=</span><span class="m">1</span> <span class="o">-</span>DUSE_CUDNN<span class="o">=</span><span class="m">1</span> <span class="o">-</span>DUSE_NVRTC<span class="o">=</span><span class="m">1</span> <span class="o">-</span>DUSE_OPENCV<span class="o">=</span><span class="m">1</span> <span class="o">-</span>DUSE_OPENMP<span class="o">=</span><span class="m">1</span> <span class="o">-</span>DUSE_BLAS<span class="o">=</span>open <span class="o">-</span>DUSE_LAPACK<span class="o">=</span><span class="m">1</span> <span class="o">-</span>DUSE_DIST_KVSTORE<span class="o">=</span><span class="m">0</span> <span class="o">-</span>DCUDA_ARCH_LIST<span class="o">=</span>Common <span class="o">-</span>DCUDA_TOOLSET<span class="o">=</span><span class="m">9.1</span> <span class="o">-</span>DCUDNN_INCLUDE<span class="o">=</span>C<span class="o">:</span>\cuda\include <span class="o">-</span>DCUDNN_LIBRARY<span class="o">=</span>C<span class="o">:</span>\cuda\lib\x64\cudnn.lib <span class="s">&quot;C:\incubator-mxnet&quot;</span>
</pre></div>
</div>
<p>NOTE: make sure the DCUDNN_INCLUDE and DCUDNN_LIBRARY pointing to the “include” and “cudnn.lib” of your CUDA installed location, and the <code class="docutils literal"><span class="pre">C:\incubator-mxnet</span></code> is the location of the source code you just git in the previous step</p>
<ol class="simple">
<li>After the CMake successfully completed, compile the the MXNet source code by using following command:</li>
</ol>
<div class="highlight-r"><div class="highlight"><pre><span></span>msbuild mxnet.sln <span class="o">/</span>p<span class="o">:</span>Configuration<span class="o">=</span>Release<span class="p">;</span>Platform<span class="o">=</span>x64 <span class="o">/</span>maxcpucount
</pre></div>
</div>
<p><strong>Option 2</strong></p>
<p>To build and install MXNet yourself using <a class="reference external" href="https://www.visualstudio.com/vs/older-downloads/">Microsoft Visual Studio 2015</a>, you need the following dependencies. Install the required dependencies:</p>
<ol class="simple">
<li>If <a class="reference external" href="https://www.visualstudio.com/vs/older-downloads/">Microsoft Visual Studio 2015</a> is not already installed, download and install it. You can download and install the free community edition.</li>
<li>Download and install <a class="reference external" href="https://cmake.org/">CMake</a> if it is not already installed.</li>
<li>Download and install <a class="reference external" href="http://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0/opencv-3.0.0.exe/download">OpenCV</a>.</li>
<li>Unzip the OpenCV package.</li>
<li>Set the environment variable <code class="docutils literal"><span class="pre">OpenCV_DIR</span></code> to point to the <code class="docutils literal"><span class="pre">OpenCV</span> <span class="pre">build</span> <span class="pre">directory</span></code> (<code class="docutils literal"><span class="pre">C:\opencv\build\x64\vc14</span></code> for example). Also, you need to add the OpenCV bin directory (<code class="docutils literal"><span class="pre">C:\opencv\build\x64\vc14\bin</span></code> for example) to the <code class="docutils literal"><span class="pre">PATH</span></code> variable.</li>
<li>If you don&#8217;t have the Intel Math Kernel Library (MKL) installed, download and install <a class="reference external" href="http://sourceforge.net/projects/openblas/files/v0.2.14/">OpenBlas</a>.</li>
<li>Set the environment variable <code class="docutils literal"><span class="pre">OpenBLAS_HOME</span></code> to point to the <code class="docutils literal"><span class="pre">OpenBLAS</span></code> directory that contains the <code class="docutils literal"><span class="pre">include</span></code> and <code class="docutils literal"><span class="pre">lib</span></code> directories. Typically, you can find the directory in <code class="docutils literal"><span class="pre">C:\Program</span> <span class="pre">files</span> <span class="pre">(x86)\OpenBLAS\</span></code>.</li>
<li>Download and install <a class="reference external" href="https://developer.nvidia.com/cuda-downloads?target_os=Windows&amp;target_arch=x86_64">CUDA</a> and <a class="reference external" href="https://developer.nvidia.com/cudnn">cuDNN</a>. To get access to the download link, register as an NVIDIA community user.</li>
</ol>
<p>After you have installed all of the required dependencies, build the MXNet source code:</p>
<ol class="simple">
<li>Download the MXNet source code from <a class="reference external" href="https://github.com/apache/incubator-mxnet">GitHub</a>.</li>
<li>Use <a class="reference external" href="https://cmake.org/">CMake</a> to create a Visual Studio solution in <code class="docutils literal"><span class="pre">./build</span></code>.</li>
<li>In Visual Studio, open the solution file,<code class="docutils literal"><span class="pre">.sln</span></code>, and compile it.
These commands produce a library called <code class="docutils literal"><span class="pre">mxnet.dll</span></code> in the <code class="docutils literal"><span class="pre">./build/Release/</span></code> or <code class="docutils literal"><span class="pre">./build/Debug</span></code> folder.</li>
</ol>
<p><p> </p>

Next, we install the <code class="docutils literal"><span class="pre">graphviz</span></code> library that we use for visualizing network graphs that you build on MXNet. We will also install <a class="reference external" href="http://jupyter.readthedocs.io/">Jupyter Notebook</a> which is used for running MXNet tutorials and examples.</p>
<ul class="simple">
<li>Install the <code class="docutils literal"><span class="pre">graphviz</span></code> by downloading the installer from the <a class="reference external" href="https://graphviz.gitlab.io/_pages/Download/Download_windows.html">Graphviz Download Page</a>.
<strong>Note</strong> Make sure to add the <code class="docutils literal"><span class="pre">graphviz</span></code> executable path to the PATH environment variable. Refer <a class="reference external" href="http://stackoverflow.com/questions/35064304/runtimeerror-make-sure-the-graphviz-executables-are-on-your-systems-path-aft">here for more details</a></li>
</ul>
<p><p> </p>
</p>
</div> <!-- End of pip -->
</div> <!-- End of GPU -->
</div> <!-- End of Python --><!-- START - Windows R CPU Installation Instructions --><div class="r">
<div class="cpu"><p>The CPU version of MXNet R package can be installed in R like other packages</p>
<div class="highlight-r"><div class="highlight"><pre><span></span>cran <span class="o">&lt;-</span> <span class="kp">getOption</span><span class="p">(</span><span class="s">&quot;repos&quot;</span><span class="p">)</span>
cran<span class="p">[</span><span class="s">&quot;dmlc&quot;</span><span class="p">]</span> <span class="o">&lt;-</span> <span class="s">&quot;https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/&quot;</span>
<span class="kp">options</span><span class="p">(</span>repos <span class="o">=</span> cran<span class="p">)</span>
install.packages<span class="p">(</span><span class="s">&quot;mxnet&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div> <!-- END - Windows R CPU --><div class="gpu"><p>The GPU version of MXNet R package can be installed in R like other packages</p>
<div class="highlight-r"><div class="highlight"><pre><span></span>cran <span class="o">&lt;-</span> <span class="kp">getOption</span><span class="p">(</span><span class="s">&quot;repos&quot;</span><span class="p">)</span>
cran<span class="p">[</span><span class="s">&quot;dmlc&quot;</span><span class="p">]</span> <span class="o">&lt;-</span> <span class="s">&quot;https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/GPU&quot;</span>
<span class="kp">options</span><span class="p">(</span>repos <span class="o">=</span> cran<span class="p">)</span>
install.packages<span class="p">(</span><span class="s">&quot;mxnet&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Alternatively, You can also follow the installation instructions <a class="reference internal" href="windows_setup.html"><span class="doc">in this guide</span></a> to build MXNet from source.</p>
</div> <!-- END of GPU -->
</div> <!-- END - Windows R --><div class="scala julia perl">
<div class="cpu gpu"><p>Follow the installation instructions <a class="reference internal" href="windows_setup.html"><span class="doc">in this guide</span></a> to set up MXNet.</p>
</div> <!-- End of cpu gpu -->
</div> <!-- End of scala julia perl -->
</div> <!-- End of Windows --><!-- START - Cloud Python Installation Instructions --><div class="cloud"><p>AWS Marketplace distributes Deep Learning AMIs (Amazon Machine Image) with MXNet pre-installed. You can launch one of these Deep Learning AMIs by following instructions in the <a class="reference external" href="http://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html">AWS Deep Learning AMI Developer Guide</a>.</p>
<p>You can also run distributed deep learning with <em>MXNet</em> on AWS using <a class="reference external" href="https://github.com/awslabs/deeplearning-cfn/blob/master/README.md">Cloudformation Template</a>.</p>
</div> <!-- END - Cloud Python Installation Instructions --><div class="devices">
  <div class="raspberry-pi"><p>MXNet supports the Debian based Raspbian ARM based operating system so you can run MXNet on Raspberry Pi Devices.</p>
<p>These instructions will walk through how to build MXNet for the Raspberry Pi and install the Python bindings for the library.</p>
<p>The complete MXNet library and its requirements can take almost 200MB of RAM, and loading large models with the library can take over 1GB of RAM. Because of this, we recommend running MXNet on the Raspberry Pi 3 or an equivalent device that has more than 1 GB of RAM and a Secure Digital (SD) card that has at least 4 GB of free memory.</p>
<p><strong>Install MXNet</strong></p>
<p>Installing MXNet is a two-step process:</p>
<ol class="simple">
<li>Build the shared library from the MXNet C++ source code.</li>
<li>Install the supported language-specific packages for MXNet.</li>
</ol>
<p><strong>Step 1</strong> Build the Shared Library</p>
<p>On Raspbian versions Wheezy and later, you need the following dependencies:</p>
<ul class="simple">
<li>Git (to pull code from GitHub)</li>
<li>libblas (for linear algebraic operations)</li>
<li>libopencv (for computer vision operations. This is optional if you want to save RAM and Disk Space)</li>
<li>A C++ compiler that supports C++ 11. The C++ compiler compiles and builds MXNet source code. Supported compilers include the following:</li>
<li><a class="reference external" href="https://gcc.gnu.org/gcc-4.8/">G++ (4.8 or later)</a></li>
</ul>
<p>Install these dependencies using the following commands in any directory:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    sudo apt-get update
    sudo apt-get -y install git cmake build-essential g++-4.8 c++-4.8 liblapack* libblas* libopencv*
</pre></div>
</div>
<p>Clone the MXNet source code repository using the following <code class="docutils literal"><span class="pre">git</span></code> command in your home directory:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    git clone https://github.com/apache/incubator-mxnet.git --recursive
    <span class="nb">cd</span> incubator-mxnet
</pre></div>
</div>
<p>If you aren&#8217;t processing images with MXNet on the Raspberry Pi, you can minimize the size of the compiled library by building MXNet without the Open Source Computer Vision (OpenCV) library with the following commands:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    <span class="nb">export</span> <span class="nv">USE_OPENCV</span> <span class="o">=</span> <span class="m">0</span>
    make
</pre></div>
</div>
<p>Otherwise, you can build the complete MXNet library with the following command:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    make
</pre></div>
</div>
<p>Executing either of these commands start the build process, which can take up to a couple hours, and creates a file called <code class="docutils literal"><span class="pre">libmxnet.so</span></code> in the mxnet/lib directory.</p>
<p>If you are getting build errors in which the compiler is being killed, it is likely that the compiler is running out of memory (especially if you are on Raspberry Pi 1, 2 or Zero, which have less than 1GB of RAM), this can often be rectified by increasing the swapfile size on the Pi by editing the file /etc/dphys-swapfile and changing the line CONF_SWAPSIZE=100 to CONF_SWAPSIZE=1024, then running:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>  sudo /etc/init.d/dphys-swapfile stop
  sudo /etc/init.d/dphys-swapfile start
  free -m <span class="c1"># to verify the swapfile size has been increased</span>
</pre></div>
</div>
<p><strong>Step 2</strong> Install MXNet Python Bindings</p>
<p>To install Python bindings run the following commands in the MXNet directory:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    <span class="nb">cd</span> python
    pip install --upgrade pip
    pip install -e .
</pre></div>
</div>
<p>Note that the <code class="docutils literal"><span class="pre">-e</span></code> flag is optional. It is equivalent to <code class="docutils literal"><span class="pre">--editable</span></code> and means that if you edit the source files, these changes will be reflected in the package installed.</p>
<p>You are now ready to run MXNet on your Raspberry Pi device. You can get started by following the tutorial on <a class="reference external" href="http://mxnet.io/tutorials/embedded/wine_detector.html">Real-time Object Detection with MXNet On The Raspberry Pi</a>.</p>
<p><em>Note - Because the complete MXNet library takes up a significant amount of the Raspberry Pi&#8217;s limited RAM, when loading training data or large models into memory, you might have to turn off the GUI and terminate running processes to free RAM.</em></p>
</div> <!-- End of raspberry pi --><div class="nvidia-jetson-tx2"><p>MXNet supports the Ubuntu Arch64 based operating system so you can run MXNet on NVIDIA Jetson Devices.</p>
<p>These instructions will walk through how to build MXNet for the Pascal based <a class="reference external" href="http://www.nvidia.com/object/embedded-systems-dev-kits-modules.html">NVIDIA Jetson TX2</a> and install the corresponding python language bindings.</p>
<p>For the purposes of this install guide we will assume that CUDA is already installed on your Jetson device.</p>
<p><strong>Install MXNet</strong></p>
<p>Installing MXNet is a two-step process:</p>
<ol class="simple">
<li>Build the shared library from the MXNet C++ source code.</li>
<li>Install the supported language-specific packages for MXNet.</li>
</ol>
<p><strong>Step 1</strong> Build the Shared Library</p>
<p>You need the following additional dependencies:</p>
<ul class="simple">
<li>Git (to pull code from GitHub)</li>
<li>libatlas (for linear algebraic operations)</li>
<li>libopencv (for computer vision operations)</li>
<li>python pip (to load relevant python packages for our language bindings)</li>
</ul>
<p>Install these dependencies using the following commands in any directory:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    sudo apt-get update
    sudo apt-get -y install git build-essential libatlas-base-dev libopencv-dev graphviz python-pip
    sudo pip install pip --upgrade
    sudo pip install setuptools numpy --upgrade
    sudo pip install graphviz jupyter
</pre></div>
</div>
<p>Clone the MXNet source code repository using the following <code class="docutils literal"><span class="pre">git</span></code> command in your home directory:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    git clone https://github.com/apache/incubator-mxnet.git --recursive
    <span class="nb">cd</span> incubator-mxnet
</pre></div>
</div>
<p>Edit the Makefile to install the MXNet with CUDA bindings to leverage the GPU on the Jetson:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    cp make/config.mk .
    <span class="nb">echo</span> <span class="s2">&quot;USE_CUDA=1&quot;</span> &gt;&gt; config.mk
    <span class="nb">echo</span> <span class="s2">&quot;USE_CUDA_PATH=/usr/local/cuda&quot;</span> &gt;&gt; config.mk
    <span class="nb">echo</span> <span class="s2">&quot;USE_CUDNN=1&quot;</span> &gt;&gt; config.mk
</pre></div>
</div>
<p>Edit the Mshadow Makefile to ensure MXNet builds with Pascal&#8217;s hardware level low precision acceleration by editing 3rdparty/mshadow/make/mshadow.mk and adding the following after line 122:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nv">MSHADOW_CFLAGS</span> <span class="o">+=</span> -DMSHADOW_USE_PASCAL<span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
<p>Now you can build the complete MXNet library with the following command:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    make -j <span class="k">$(</span>nproc<span class="k">)</span>
</pre></div>
</div>
<p>Executing this command creates a file called <code class="docutils literal"><span class="pre">libmxnet.so</span></code> in the mxnet/lib directory.</p>
<p><strong>Step 2</strong> Install MXNet Python Bindings</p>
<p>To install Python bindings run the following commands in the MXNet directory:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    <span class="nb">cd</span> python
    pip install --upgrade pip
    pip install -e .
</pre></div>
</div>
<p>Note that the <code class="docutils literal"><span class="pre">-e</span></code> flag is optional. It is equivalent to <code class="docutils literal"><span class="pre">--editable</span></code> and means that if you edit the source files, these changes will be reflected in the package installed.</p>
<p>Add the mxnet folder to the path:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>    <span class="nb">cd</span> ..
    <span class="nb">export</span> <span class="nv">MXNET_HOME</span><span class="o">=</span><span class="k">$(</span><span class="nb">pwd</span><span class="k">)</span>
    <span class="nb">echo</span> <span class="s2">&quot;export PYTHONPATH=</span><span class="nv">$MXNET_HOME</span><span class="s2">/python:</span><span class="nv">$PYTHONPATH</span><span class="s2">&quot;</span> &gt;&gt; ~/.bashrc
    <span class="nb">source</span> ~/.bashrc
</pre></div>
</div>
<p>You are now ready to run MXNet on your NVIDIA Jetson TX2 device.</p>
</div> <!-- End of jetson -->
</div> <!-- End of devices --><!-- This # tag restarts the page and allows reuse
 of the div classes for validation sections, etc --></div>
<div class="section" id="validate-mxnet-installation">
<span id="validate-mxnet-installation"></span><h1>Validate MXNet Installation<a class="headerlink" href="#validate-mxnet-installation" title="Permalink to this headline">¶</a></h1>
<div class="linux macos">
  <div class="python">
    <div class="cpu"><div class="pip build-from-source"><p>Start the python terminal.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ python
</pre></div>
</div>
</div><div class="docker"><p>Launch a Docker container with <code class="docutils literal"><span class="pre">mxnet/python</span></code> image and run example <em>MXNet</em> python program on the terminal.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ docker run -it mxnet/python bash <span class="c1"># Use sudo if you skip Step 2 in the installation instruction</span>

<span class="c1"># Start a python terminal</span>
root@4919c4f58cac:/# python
</pre></div>
</div>
</div><div class="virtualenv"><p>Activate the virtualenv environment created for <em>MXNet</em>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ <span class="nb">source</span> ~/mxnet/bin/activate
</pre></div>
</div>
<p>After activating the environment, you should see the prompt as below.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="o">(</span>mxnet<span class="o">)</span>$
</pre></div>
</div>
<p>Start the python terminal.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ python
</pre></div>
</div>
</div><p>Run a short <em>MXNet</em> python program to create a 2X3 matrix of ones, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mxnet</span> <span class="kn">as</span> <span class="nn">mx</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">a</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span>
<span class="go">array([[ 3.,  3.,  3.],</span>
<span class="go">       [ 3.,  3.,  3.]], dtype=float32)</span>
</pre></div>
</div>
</div>
</div>
</div><!-- Validate Windows CPU pip install --><div class="windows">
  <div class="python">
    <div class="cpu">
      <div class="pip"><p>Run a short <em>MXNet</em> python program to create a 2X3 matrix of ones, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mxnet</span> <span class="kn">as</span> <span class="nn">mx</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">a</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span>
<span class="go">array([[ 3.,  3.,  3.],</span>
<span class="go">       [ 3.,  3.,  3.]], dtype=float32)</span>
</pre></div>
</div>
</div>
</div>
</div>
</div><!-- Mac OS GPU installation validation --><div class="macos">
  <div class="python">
    <div class="gpu"><div class="pip virtualenv docker">
</br><p>Will be available soon.</p>
</div><div class="build-from-source">
</br><p>From the MXNet root directory run: <code class="docutils literal"><span class="pre">python</span> <span class="pre">example/image-classification/train_mnist.py</span> <span class="pre">--network</span> <span class="pre">lenet</span> <span class="pre">--gpus</span> <span class="pre">0</span></code> to test GPU training.</p>
</div>
</div>
</div>
</div><!-- Windows GPU installation validation --><div class="windows">
  <div class="python">
    <div class="gpu"><div class="virtualenv docker">
</br><p>Will be available soon.</p>
</div><div class="pip build-from-source">
</br><p>From the MXNet root directory run: <code class="docutils literal"><span class="pre">python</span> <span class="pre">example/image-classification/train_mnist.py</span> <span class="pre">--network</span> <span class="pre">lenet</span> <span class="pre">--gpus</span> <span class="pre">0</span></code> to test GPU training.</p>
</div>
</div>
</div>
</div><!-- Validation for GPU machines --><div class="linux">
  <div class="python">
    <div class="gpu"><div class="pip build-from-source"><p>Start the python terminal.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ python
</pre></div>
</div>
</div><div class="docker"><p>Launch a NVIDIA Docker container with <code class="docutils literal"><span class="pre">mxnet/python:gpu</span></code> image and run example <em>MXNet</em> python program on the terminal.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ nvidia-docker run -it mxnet/python:gpu bash <span class="c1"># Use sudo if you skip Step 2 in the installation instruction</span>

<span class="c1"># Start a python terminal</span>
root@4919c4f58cac:/# python
</pre></div>
</div>
</div><div class="virtualenv"><p>Activate the virtualenv environment created for <em>MXNet</em>.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ <span class="nb">source</span> ~/mxnet/bin/activate
</pre></div>
</div>
<p>After activating the environment, you should see the prompt as below.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="o">(</span>mxnet<span class="o">)</span>$
</pre></div>
</div>
<p>Start the python terminal.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ python
</pre></div>
</div>
</div><p>Run a short <em>MXNet</em> python program to create a 2X3 matrix of ones <em>a</em> on a <em>GPU</em>, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3. We use <em>mx.gpu()</em>, to set <em>MXNet</em> context to be GPUs.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mxnet</span> <span class="kn">as</span> <span class="nn">mx</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">mx</span><span class="o">.</span><span class="n">gpu</span><span class="p">())</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">a</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span>
<span class="go">array([[ 3.,  3.,  3.],</span>
<span class="go">       [ 3.,  3.,  3.]], dtype=float32)</span>
</pre></div>
</div>
</div>
</div>
</div><!-- Linux Clean up -->
<div class="linux">
  <div class="python">
    <div class="cpu"><div class="pip build-from-source"><p>Exit the Python terminal.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">exit</span><span class="p">()</span>
<span class="go">$</span>
</pre></div>
</div>
</div><div class="virtualenv"><p>Exit the Python terminal and Deactivate the virtualenv <em>MXNet</em> environment.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">exit</span><span class="p">()</span>
<span class="go">(mxnet)$ deactivate</span>
<span class="go">$</span>
</pre></div>
</div>
</div><div class="docker"><p>Exit the Python terminal and mxnet/python docker container.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">exit</span><span class="p">()</span>
<span class="go">root@4919c4f58cac:/# exit</span>
</pre></div>
</div>
</div></div>
</div>
</div><!-- MacOS Clean up -->
<div class="macos">
  <div class="python">
    <div class="cpu"><div class="pip build-from-source"><p>Exit the Python terminal.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">exit</span><span class="p">()</span>
<span class="go">$</span>
</pre></div>
</div>
</div><div class="virtualenv"><p>Exit the Python terminal and Deactivate the virtualenv <em>MXNet</em> environment.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">exit</span><span class="p">()</span>
<span class="go">(mxnet)$ deactivate</span>
<span class="go">$</span>
</pre></div>
</div>
</div><div class="docker"><p>Exit the Python terminal and then the docker container.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">exit</span><span class="p">()</span>
<span class="go">root@4919c4f58cac:/# exit</span>
</pre></div>
</div>
</div></div>
</div>
</div><!-- Validation for cloud installation --><div class="cloud"><p>Login to the cloud instance you launched, with pre-installed <em>MXNet</em>, following the guide by corresponding cloud provider.</p>
<p>Start the python terminal.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ python
</pre></div>
</div>
<!-- Example Python code for CPU --><div class="cpu"><p>Run a short <em>MXNet</em> python program to create a 2X3 matrix of ones, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mxnet</span> <span class="kn">as</span> <span class="nn">mx</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">a</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span>
<span class="go">array([[ 3.,  3.,  3.],</span>
<span class="go">         [ 3.,  3.,  3.]], dtype=float32)</span>
</pre></div>
</div>
<p>Exit the Python terminal.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">exit</span><span class="p">()</span>
<span class="go">$</span>
</pre></div>
</div>
</div><!-- Example Python code for CPU --><div class="gpu"><p>Run a short <em>MXNet</em> python program to create a 2X3 matrix of ones <em>a</em> on a <em>GPU</em>, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3. We use <em>mx.gpu()</em>, to set <em>MXNet</em> context to be GPUs.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mxnet</span> <span class="kn">as</span> <span class="nn">mx</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">mx</span><span class="o">.</span><span class="n">gpu</span><span class="p">())</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">a</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span>
<span class="go">array([[ 3.,  3.,  3.],</span>
<span class="go">       [ 3.,  3.,  3.]], dtype=float32)</span>
</pre></div>
</div>
</div></div><!-- Example R code for CPU --><div class="linux macos windows">
  <div class="r">
    <div class="cpu"><p>Run a short <em>MXNet</em> R program to create a 2X3 matrix of ones, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3.</p>
<div class="highlight-r"><div class="highlight"><pre><span></span><span class="kn">library</span><span class="p">(</span>mxnet<span class="p">)</span>
a <span class="o">&lt;-</span> mx.nd.ones<span class="p">(</span><span class="kt">c</span><span class="p">(</span><span class="m">2</span><span class="p">,</span><span class="m">3</span><span class="p">),</span> ctx <span class="o">=</span> mx.cpu<span class="p">())</span>
b <span class="o">&lt;-</span> a <span class="o">*</span> <span class="m">2</span> <span class="o">+</span> <span class="m">1</span>
b
</pre></div>
</div>
</div>
</div>
</div><!-- Example R code for GPU --><div class="linux macos windows">
  <div class="r">
    <div class="gpu"><p>Run a short <em>MXNet</em> R program to create a 2X3 matrix of ones <em>a</em> on a <em>GPU</em>, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3. We use <em>mx.gpu()</em>, to set <em>MXNet</em> context to be GPUs.</p>
<div class="highlight-r"><div class="highlight"><pre><span></span><span class="kn">library</span><span class="p">(</span>mxnet<span class="p">)</span>
a <span class="o">&lt;-</span> mx.nd.ones<span class="p">(</span><span class="kt">c</span><span class="p">(</span><span class="m">2</span><span class="p">,</span><span class="m">3</span><span class="p">),</span> ctx <span class="o">=</span> mx.gpu<span class="p">())</span>
b <span class="o">&lt;-</span> a <span class="o">*</span> <span class="m">2</span> <span class="o">+</span> <span class="m">1</span>
b
</pre></div>
</div>
</div>
</div>
</div><div class="linux">
  <div class="scala julia perl">
    <div class="cpu gpu"><p>Will be available soon.</p>
</div>
</div>
</div><div class="macos">
  <div class="scala julia perl">
    <div class="cpu gpu"><p>Will be available soon.</p>
</div>
</div>
</div><!-- Windows MXNet Installation validation -->
<div class="windows">
  <div class="python">
    <div class="cpu"><div class="build-from-source virtualenv docker">
<br/>
Will be available soon.
</div></div>
</div><div class="scala julia perl">
<div class="cpu gpu"><p>Will be available soon.</p>
</div>
</div>
</div>
<!-- End Windows Installation validation --><div class="devices">
  <div class="raspberry-pi"><p>Will be available soon.</p>
</div>
<div class="nvidia-jetson-tx2"><p>Will be available soon.</p>
</div>
</div></div>
<div class="section" id="download-source-package">
<span id="download-source-package"></span><h1>Download Source Package<a class="headerlink" href="#download-source-package" title="Permalink to this headline">¶</a></h1>
</div>


        </div>
      </div>
      
      <div class="sphinxsidebar rightsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Installing MXNet</a></li>
<li><a class="reference internal" href="#validate-mxnet-installation">Validate MXNet Installation</a></li>
<li><a class="reference internal" href="#download-source-package">Download Source Package</a></li>
</ul>

        </div>
      </div>
    </div><div class="footer">
<div class="section-disclaimer">
<div class="container">
    <div>
        <img src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/apache_incubator_logo.png" height=60>
        <p>
            Apache MXNet is an effort undergoing incubation at The Apache Software Foundation (ASF), <strong>sponsored by the <i>Apache Incubator</i></strong>. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
        </p>
        <p>
            "Copyright © 2017-2018, The Apache Software Foundation
            Apache MXNet, MXNet, Apache, the Apache feather, and the Apache MXNet project logo are either registered trademarks or trademarks of the Apache Software Foundation."
        </p>
    </div>
</div>
</div>
</div> <!-- pagename != index -->
    </div>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
    <script type="text/javascript" src="../_static/js/sidebar.js"></script>
    <script type="text/javascript" src="../_static/js/search.js"></script>
    <script type="text/javascript" src="../_static/js/navbar.js"></script>
    <script type="text/javascript" src="../_static/js/clipboard.min.js"></script>
    <script type="text/javascript" src="../_static/js/copycode.js"></script>
    <script type="text/javascript" src="../_static/js/page.js"></script>
    <script type="text/javascript">
        $('body').ready(function () {
            $('body').css('visibility', 'visible');
        });
    </script>
  </body>
</html>
